using namespace std;
#include <iostream>


void qksortRecur (int list[], int first, int last) {
	int pivot; //Central point for dividing into sub-arrays and swapping variables
	int temp, count, left=0, right=last, templ, tempr;
	if(last>=1){
		pivot=(last+1)/2;//So long as there are two or more values to sort
		for(count=0;count<=last;count++){
			while(list[left]<pivot){//Pinpoint outermost value to swap on left side of pivot
				left++;
			}
			while(list[right]>pivot){//pinpoint outermost value to swap on right side of pivot
				right--;
			}
			if(list[left]>pivot){//Swap chosen values
				templ=list[left];
				tempr=list[right];
				list[left]=tempr;
				list[right]=templ;
			}
			else;
			
			
		}
		temp=pivot+1;
		//This is where my code is failing.  Beyond this point nothing happens when I put a cout in
		qksortRecur(list, 0, pivot);
		qksortRecur(list, temp, last);
		

	}
	

} // quicksortRecur


void quicksort(int arr[], int numEntries) {
	// sorts the first numEntries in arr
    qksortRecur(arr, 0, numEntries - 1);
}


void printArray(int array[], int numEntries) {
// outputs the first numEntries in array
    for (int i = 0; i < numEntries; i++)
		cout <<"  " <<array[i];
    cout <<endl;
}

int main(void) {
	int A[] = { 96, 43, 20, 25, 55, 32, 43, 19, 22, 68, 87, 11, 84, 28 };
    cout <<"Before sorting:";
    printArray(A, 14);
    quicksort(A, 14);
    cout <<" After sorting:";
    printArray(A, 14);
}
